function e() {

		var iosocket = io.connect();
		iosocket.on('connect', function() {
			iosocket.on('disconnect', function() {
				
				//断线处理
			});

			iosocket.on('bet', function(message) {
				//alert("receive bet info---------------------------!" + message.beiLv);
				if ($("#tt").find("tr").length > 100) {
					$("#tt tr:last").remove(); //这个是删除
				}
				$('#tt').prepend(
						'<tr><td>' + message.name
								+ '</td><td>' + message.time
								+ '</td><td>' + message.bill
								+ '</td><td>' + message.jiLv + "%"
								+ '</td><td style="font-weight:bold;font-size:15px;">' + message.luck
								+ '</td><td style="font-weight:bold;font-size:15px;">'
								+ message.condition
								+ '</td><td>'
								+ (message.betSize+"")
								+ '</td><td>' + message.beiLv
								+ '</td><td style="font-weight:bold;font-size:15px;">'
								+ message.profit + '</td></tr>');
			});

			iosocket.on('initBetList', function(objs) {
				
				$.each(objs, function(n, message) {
					if ($("#tt").find("tr").length > 100) {
						$("#tt tr:last").remove(); //这个是删除
					}
					$('#tt').append(
							'<tr><td>' + message.name
									+ '</td><td>'
									+ message.time
									+ '</td><td>'
									+ message.bill
									+ '</td><td>' + message.jiLv + "%"
									+ '</td><td style="font-weight:bold;font-size:15px;">'
									+ message.luck
									+ '</td><td style="font-weight:bold;font-size:15px;">'
									+ message.condition
									+ '</td><td>'
									+ (message.betSize+"")
									+ '</td><td>'
									+ message.beiLv
									+ '</td><td style="font-weight:bold;font-size:15px;">'
									+ message.profit + '</td></tr>');

				});
			});
			
			iosocket.on('myBet', function(message) {
				
				if ($("#tt_mybets").find("tr").length > 100) {
					$("#tt_mybets tr:last").remove(); //这个是删除
				}
				$('#tt_mybets').prepend(
						'<tr><td>' + message.name
								+ '</td><td>' + message.time
								+ '</td><td>' + message.bill
								+ '</td><td>' + message.jiLv + "%"
								+ '</td><td style="font-weight:bold;font-size:15px;">' + message.luck
								+ '</td><td style="font-weight:bold;font-size:15px;">'
								+ message.condition
								+ '</td><td>'
								+ message.betSize
								+ '</td><td>' + message.beiLv
								+ '</td><td style="font-weight:bold;font-size:15px;">'
								+ message.profit + '</td></tr>');
			});
			
			iosocket.on('myBetList', function(objs) {
				
				$.each(objs, function(n, message) {
					if ($("#tt_mybets").find("tr").length > 100) {
						$("#tt_mybets tr:last").remove(); //这个是删除
					}
					$('#tt_mybets').append(
							'<tr><td>' + message.name
									+ '</td><td>'
									+ message.time
									+ '</td><td>'
									+ message.bill
									+ '</td><td>' + message.jiLv + "%"
									+ '</td><td style="font-weight:bold;font-size:15px;">'
									+ message.luck
									+ '</td><td style="font-weight:bold;font-size:15px;">'
									+ message.condition
									+ '</td><td>'
									+ message.betSize
									+ '</td><td>'
									+ message.beiLv
									+ '</td><td style="font-weight:bold;font-size:15px;">'
									+ message.profit + '</td></tr>');
				});
			});
			iosocket.on('error', function(message) {
				var errorMsg = message.msg;
				alert(errorMsg);
				return;
			});
			
			iosocket.on('user', function(user) {
				if(null != user){
					$(".registTog").text("User:  " + user.name);
					$(".registTog").css({"font-weight":"bold", "font-size":"16px"});
					$(".registTog").unbind('click').removeAttr('onclick');  // 删除原事件

					$(".loginTog").text("Exit");
					$(".loginTog").unbind('click').removeAttr('onclick').click(function(e){
						location.href="/logout";
					});
				}
				
				return;
			});
			
			iosocket.on('userStatus', function(userStatus) {

				if(null != userStatus){
					$("#user_btc_amount").text(userStatus.totalEarnQty.toFixed(8));
					$("#user_stat_win_count").text(userStatus.totalWinQty.toFixed(8));
					$("#user_stat_loss_count").text(userStatus.totalLoseQty.toFixed(8));
					$("#user_stat_wagered").text(userStatus.totalWagerQty.toFixed(8));
				}
				
				return;
			});
			
			/*iosocket.on('user', function(userStatus) {
				$("#user_btc_amount").text(userStatus.totalEarnQty.toFixed(8));
				$("#user_stat_win_count").text(userStatus.totalWinQty.toFixed(8));
				$("#user_stat_loss_count").text(userStatus.totalLoseQty.toFixed(8));
				$("#user_stat_wagered").text(userStatus.totalWagerQty.toFixed(8));
				return;
			});*/
			iosocket.on('globalData', function(globalData) {
				if(null != globalData){
					$("#site_bet_count").text(globalData.totalBetCount);
					
					$("#site_bankroll").text(Number(globalData.bankRoll).toFixed(8));
					$("#site_stat_wagered").text(Number(globalData.totalBetQty).toFixed(8));
					$("#site_max_bet_profit").text(Number(globalData.maxWinQty).toFixed(8));
				}
				return;
			});
			
			iosocket.on('chat', function(message) {
				$("#chatTxt").append("<font color='green'>" + message.name + "</font>" + " say: " + message.txt + "<br />");
			});
			
			
			$("#sendChat").click(function(e){
				
				var txt = $("#chatSend").val();
				
				iosocket.emit("chat", {txt:txt});
			});
			
			var isPrintableKey = function(k) {
				return (k >= 48 && k <= 57) || // 数字
				(k >= 96 && k <= 105) || // 小键盘数字
				// 其他符号键
				(k === 110) || (k === 8);
			};

			String.prototype.trim = function() {  
				return this.replace(/^\s+/g,"").replace(/\s+$/g,"");  
			};
			
			$('#btn_roll_high').click(function() {
				alert("bet big");
				var data = {
					beiLv : $('#payout').val(),
					betSize : $('#bet_amount').val(),
					type : 1
				};
				iosocket.emit("bet", data);
			});

			$('#btn_roll_low').click(function() {
				alert("bet small");
				var data = {
					beiLv : $('#payout').val(),
					betSize : $('#bet_amount').val(),
					type : 0
				};
				iosocket.emit("bet", data);
			});
			
			$("#regist_act").click(function(){
				/*var accountName = $("#accountName").val();
				var accountNewPassword = $("#accountNewPassword").val();
				var accountConfirmPassword = $("#accountConfirmPassword").val();
				if(accountName == null || accountName.trim() == "" || accountName.trim().length < 6){
					alert("account Name length at least 6!");
					return;
				}
				if(accountNewPassword == null || accountNewPassword.trim() == "" || accountNewPassword.trim().length < 6){
					alert("accountNewPassword length at least 6!");
					return;
				}
				if(accountNewPassword != accountConfirmPassword)return alert("accountNewPassword != accountConfirmPassword");*/

				$("#registForm").submit();
				return true;
				//iosocket.emit("registAct", {name:accountName, password:accountNewPassword});
			});
			
			$("#login_act").click(function(e){
				/*var accountName = $("#accountNameRegist").val();
				alert(accountName);
				var accountNewPassword = $("#accountNewPasswordRegist").val();
				
				if(accountName == null || accountName.trim() == "" || accountName.trim().length < 6){
					alert("account Name length at least 6!");
					return;
				}
				if(accountNewPassword == null || accountNewPassword.trim() == "" || accountNewPassword.trim().length < 6){
					alert("accountNewPassword length at least 6!");
					return;
				}*/
				
				$("#loginForm").submit();
				return true;
				//iosocket.emit("registAct", {name:accountName, password:accountNewPassword});
			});
			/*$("#loginout").click(function(){
				$("#registForm").submit();
				location.href="/logout";
			});*/
			

			
			$("button[data-toggle='tab']").click(function(e){
				if($(this).hasClass("active"))return;
				$.each($(this).parent().children(), function(n, obj){
					if($(obj).attr("tagName") == "BUTTON"){
						
						if($(obj).hasClass("active")){
							$(obj).removeClass("active");
							$($(obj).attr("data-target")).removeClass("active");
						}
					}
				});
				$(this).addClass("active");
				$($(this).attr("data-target")).addClass("active");
			});
			
			$("a[data-toggle='tab']").click(function(e){
				if($(this).parent().hasClass("active"))return;
				$.each($(this).parent().parent().children(), function(n, obj){
					
					if($(obj).attr("tagName") == "LI"){
						var child = $(obj).children()[0];

						if($(obj).hasClass("active")){
							$(obj).removeClass("active");
							$($(child).attr("data_target")).removeClass("active");
						}
					}
				});
				
				$(this).parent().addClass("active");
				$($(this).attr("data_target")).addClass("active");
			});
			
			
			//TODO all selector
			$("[id=model]").click(function(e){
				
				$($(this).attr("modal-target")).removeClass("hide").removeClass("fade");
				//iosocket.emit("registAct", {name:"test"});
			});
			
			$("[id=closeModal]").click(function(e){
				$($(this).attr("data-dismiss")).addClass("fade").addClass("hide");
			});
			
			$("[id=cancelModal]").click(function(e){
				$($(this).attr("data-dismiss")).addClass("fade").addClass("hide");
			});
			
			var manualCal = function(jId){

				if(jId == "#payout"){
					
					$('#win_odds').val('');
					if($(jId).val() == 0){
						$('#win_odds').val(0);
					}else{
						$('#win_odds').val(numDiv(99, $(jId).val(), 2));
					}
					
					$("#roll_high").html("&gt; " + $('#win_odds').val());
					$("#roll_low").html("&lt; " + numSub(100, $('#win_odds').val()));
					
					var a = numSub($(jId).val(), 1);
					var b = numMulti(a, $("#bet_amount").val());
					$('#bet_profit').val(b.toFixed(8));
				}else if(jId == "#win_odds"){
					
					$('#payout').val('');
					if($(jId).val() == 0){
						$('#payout').val(0);
					}else{
						$('#payout').val(numDiv(99, $(jId).val(), 2));
					}
					
					$("#roll_high").html("&gt; " + $('#win_odds').val());
					$("#roll_low").html("&lt; " + numSub(100, $('#win_odds').val()));
					
					var a = numSub($('#payout').val(), 1);
					var b = numMulti(a, $("#bet_amount").val());
					$('#bet_profit').val(b.toFixed(8));
				}else if(jId == "#bet_amount"){
					
					$('#bet_profit').val('');
					var a = numSub($('#payout').val(), 1);
					var b = numMulti(a, $(jId).val());
					$('#bet_profit').val(b.toFixed(8));
				}
				
				if($("#payout").val() > 99000 || $("#payout").val() < 1.01 ){
					$("#payout").css("color", "red");
				}else{
					$("#payout").css("color", "");
				}
				
				if($('#win_odds').val() > 98 || $('#win_odds').val() < 0.0001 ){
					$('#win_odds').css("color", "red");
				}else{
					$('#win_odds').css("color", "");
				}
				
				if($('#bet_amount').val() > 1000 || $('#bet_amount').val() < 0.0000001 ){
					$('#bet_amount').css("color", "red");
				}else{
					$('#bet_amount').css("color", "");
				}
			};
			$('#win_odds').keyup(function(event) {
				
				if (!isPrintableKey(event.which))
					return;
				manualCal('#win_odds');
			});
			$('#payout').keyup(function(event) {
				if (!isPrintableKey(event.which))
					return;
				manualCal('#payout');
			});
			$('#bet_amount').keyup(function(event) {
				if (!isPrintableKey(event.which))
					return;
				manualCal('#bet_amount');
			});
		});

		
		
		
		/*var http = require('http');
		var querystring = require('querystring');


		var post_data = querystring.stringify({
		         product : 'club',
		         sign : 'ddddddddddddddd',
		         sender: '发送者的名字:超级管理员',
		         uids : ['ffwq@qq.com', 'ffqwf@www.com'],
		         msg : 'wwww'
		});

		var options = {
		    host: '10.11.442.33',
		    port: 80,
		    path: '/ww1',
		    method: 'POST'
		};


		var req = http.request(options, function(res) {
		  console.log('STATUS: ' + res.statusCode);
		  console.log('HEADERS: ' + JSON.stringify(res.headers));
		  res.setEncoding('utf8');
		  res.on('data', function (chunk) {
		    console.log('BODY: ' + chunk);
		  });
		});

		// write data to request body
		req.write(post_data + "\n");
		req.end();*/
		
	}